/*
* ======================================================================
* ----------------------------------------------------------------------
* Comments:    --
* Author  :    Angwyn
* Website :    http://www.ah-shared.blogspot.com
* ----------------------------------------------------------------------
* Please don't use this before get permission from the author
* credit by AH-SHARED
* ----------------------------------------------------------------------
* ======================================================================
*/


//<![CDATA[
var Cur_Url_ThreadCM = window.location.href;
var Cm_Block = document.getElementById('cm_block');
var Cm_Block_Content = Cm_Block.innerHTML;
var Cm_Item_Id = [];
var Cm_Item_Content = [];
var Cm_Item_Level = [];
var Cm_Num = 0;
var Cm_Item_Id_T = '';
var Cm_Item_Content_T = '';
var Cm_Item_Level_T = '';
var i = 0;
var j = 0;
var k = 0;
var h = 0;
var strout = '';
var str_t1 = "";
var str_t2 = "";

function getInternetExplorerVersion() {
    var rv = -1;
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");
        if (re.exec(ua) != null) rv = parseFloat(RegExp.$1)
    }
    return rv
}
var IE_ver = getInternetExplorerVersion();
if (IE_ver == -1 || IE_ver >= 9) {
    while (Cm_Block_Content.indexOf('id="c') != -1) {
        i = Cm_Block_Content.indexOf('id="c');
        Cm_Block_Content = Cm_Block_Content.substring(i + 4);
        i = Cm_Block_Content.indexOf('"');
        Cm_Item_Id[Cm_Num] = Cm_Block_Content.substring(0, i);
        Cm_Block_Content = Cm_Block_Content.substring(i);
        Cm_Item_Content[Cm_Num] = document.getElementById(Cm_Item_Id[Cm_Num]).innerHTML;
        Cm_Item_Level[Cm_Num] = 0;
        Cm_Num++
    }
    for (i = 0; i < Cm_Num - 1; i++) {
        for (j = i + 1; j < Cm_Num; j++) {
            if (Cm_Item_Content[j].indexOf(Cm_Item_Id[i]) != -1) {
                Cm_Item_Id_T = Cm_Item_Id[j];
                Cm_Item_Content_T = Cm_Item_Content[j];
                Cm_Item_Level[j] = Cm_Item_Level[i] + 1;
                Cm_Item_Level_T = Cm_Item_Level[j];
                for (h = i + 1; h < j; h++) {
                    if (Cm_Item_Level[h] < Cm_Item_Level_T) {
                        break
                    }
                }
                for (k = j; k > h; k = k - 1) {
                    Cm_Item_Id[k] = Cm_Item_Id[k - 1];
                    Cm_Item_Content[k] = Cm_Item_Content[k - 1];
                    Cm_Item_Level[k] = Cm_Item_Level[k - 1]
                }
                Cm_Item_Id[h] = Cm_Item_Id_T;
                Cm_Item_Content[h] = Cm_Item_Content_T;
                Cm_Item_Level[h] = Cm_Item_Level_T
            }
        }
    }
    for (i = 0; i < Cm_Num; i++) {
        j = Cm_Item_Content[i].indexOf('@<a href="#c');
        if (j != -1) {
            str_t1 = Cm_Item_Content[i].substring(0, j);
            str_t2 = Cm_Item_Content[i].substring(j + 1);
            j = str_t2.indexOf('</a>');
            str_t2 = str_t2.substring(j + 4);
            Cm_Item_Content[i] = str_t1 + str_t2
        }
        j = Cm_Item_Content[i].indexOf('class="cm_wrap"');
        if (j != -1) {
            str_t1 = Cm_Item_Content[i].substring(0, j);
            str_t2 = Cm_Item_Content[i].substring(j);
            if (Cm_Item_Level[i] > 6) Cm_Item_Level[i] = 6;
            Cm_Item_Content[i] = str_t1 + 'style="width:' + (100 - Cm_Item_Level[i] * 5) + '%" ' + str_t2
        }
        strout += Cm_Item_Content[i]
    }
    strout += '<div class="clear"></div>';
    Cm_Block.innerHTML = strout;
    Cm_Block.style.display = 'block';
    var Cm_Total_Obj = document.getElementById('cm_total').innerHTML;
    var Cm_Total = parseInt(Cm_Total_Obj);
    if (Cm_Total > 200) {
        strout = '<div style="float:left">Page ';
        var Cm_Page_Num = (Cm_Total - Cm_Total % 200) / 200 + 1;
        var Org_Url_ThreadCM = '';
        var Cm_Cur_Page = 1;
        i = Cur_Url_ThreadCM.indexOf('.html');
        if (i != -1) {
            Org_Url_ThreadCM = Cur_Url_ThreadCM.substring(0, i + 5)
        } else {
            Org_Url_ThreadCM = Cur_Url_ThreadCM
        }
        i = Org_Url_ThreadCM.indexOf('#comments');
        if (i != -1) {
            Org_Url_ThreadCM = Org_Url_ThreadCM.substring(0, i)
        }
        i = Cur_Url_ThreadCM.indexOf('?commentPage=');
        if (i == -1) {
            Cm_Cur_Page = 1
        } else {
            Cm_Cur_Page = parseInt(Cur_Url_ThreadCM.substring(i + 13))
        }
        for (i = 1; i <= Cm_Page_Num; i++) {
            if (i == Cm_Cur_Page) {
                strout += '<span>' + i + '</span>'
            } else {
                strout += '<a href="' + Org_Url_ThreadCM + '?commentPage=' + i + '#comments">' + i + '</a>'
            }
        }
        if (Cm_Cur_Page * 200 <= Cm_Total) {
            strout += '</div><div style="float:right">' + (((Cm_Cur_Page - 1) * 200) + 1) + ' - ' + (Cm_Cur_Page * 200) + ' of ' + Cm_Total + ' comments</div>'
        } else {
            strout += '</div><div style="float:right">' + (((Cm_Cur_Page - 1) * 200) + 1) + ' - ' + Cm_Total + ' of ' + Cm_Total + ' comments</div>'
        }
        var Cm_Page_Obj = document.getElementById('cm_page');
        Cm_Page_Obj.innerHTML = strout;
        Cm_Page_Obj = document.getElementById('cm_page_copy');
        Cm_Page_Obj.innerHTML = strout;
        if (Cm_Cur_Page < Cm_Page_Num) {
            strout = '<style type="text/css">.cm_author_reply {display: none}</style>';
            var Cm_ReplyCSS_Obj = document.getElementById('cm_reply_css');
            Cm_ReplyCSS_Obj.innerHTML = strout
        }
    }
} else {
    while (Cm_Block_Content.indexOf('id=c') != -1) {
        i = Cm_Block_Content.indexOf('id=c');
        Cm_Block_Content = Cm_Block_Content.substring(i + 3);
        i = Cm_Block_Content.indexOf('>');
        Cm_Item_Id[Cm_Num] = Cm_Block_Content.substring(0, i);
        Cm_Block_Content = Cm_Block_Content.substring(i);
        Cm_Item_Content[Cm_Num] = document.getElementById(Cm_Item_Id[Cm_Num]).innerHTML;
        Cm_Item_Level[Cm_Num] = 0;
        Cm_Num++
    }
    for (i = 0; i < Cm_Num - 1; i++) {
        for (j = i + 1; j < Cm_Num; j++) {
            if (Cm_Item_Content[j].indexOf(Cm_Item_Id[i]) != -1) {
                Cm_Item_Id_T = Cm_Item_Id[j];
                Cm_Item_Content_T = Cm_Item_Content[j];
                Cm_Item_Level[j] = Cm_Item_Level[i] + 1;
                Cm_Item_Level_T = Cm_Item_Level[j];
                for (h = i + 1; h < j; h++) {
                    if (Cm_Item_Level[h] < Cm_Item_Level_T) {
                        break
                    }
                }
                for (k = j; k > h; k = k - 1) {
                    Cm_Item_Id[k] = Cm_Item_Id[k - 1];
                    Cm_Item_Content[k] = Cm_Item_Content[k - 1];
                    Cm_Item_Level[k] = Cm_Item_Level[k - 1]
                }
                Cm_Item_Id[h] = Cm_Item_Id_T;
                Cm_Item_Content[h] = Cm_Item_Content_T;
                Cm_Item_Level[h] = Cm_Item_Level_T
            }
        }
    }
    for (i = 0; i < Cm_Num; i++) {
        j = Cm_Item_Content[i].indexOf('@<A href="#c');
        if (j != -1) {
            str_t1 = Cm_Item_Content[i].substring(0, j);
            str_t2 = Cm_Item_Content[i].substring(j + 1);
            j = str_t2.indexOf('</A>');
            str_t2 = str_t2.substring(j + 4);
            Cm_Item_Content[i] = str_t1 + str_t2
        }
        j = Cm_Item_Content[i].indexOf('class=cm_wrap');
        if (j != -1) {
            str_t1 = Cm_Item_Content[i].substring(0, j);
            str_t2 = Cm_Item_Content[i].substring(j);
            if (Cm_Item_Level[i] > 6) Cm_Item_Level[i] = 6;
            Cm_Item_Content[i] = str_t1 + 'style="width:' + (100 - Cm_Item_Level[i] * 5) + '%" ' + str_t2
        }
        strout += Cm_Item_Content[i]
    }
    strout += '<div class="clear"></div>';
    Cm_Block.innerHTML = strout;
    Cm_Block.style.display = 'block';
    var Cm_Total_Obj = document.getElementById('cm_total').innerHTML;
    var Cm_Total = parseInt(Cm_Total_Obj);
    if (Cm_Total > 200) {
        strout = '<div style="float:left">Page ';
        var Cm_Page_Num = (Cm_Total - Cm_Total % 200) / 200 + 1;
        var Org_Url_ThreadCM = '';
        var Cm_Cur_Page = 1;
        i = Cur_Url_ThreadCM.indexOf('.html');
        if (i != -1) {
            Org_Url_ThreadCM = Cur_Url_ThreadCM.substring(0, i + 5)
        } else {
            Org_Url_ThreadCM = Cur_Url_ThreadCM
        }
        i = Org_Url_ThreadCM.indexOf('#comments');
        if (i != -1) {
            Org_Url_ThreadCM = Org_Url_ThreadCM.substring(0, i)
        }
        i = Cur_Url_ThreadCM.indexOf('?commentPage=');
        if (i == -1) {
            Cm_Cur_Page = 1
        } else {
            Cm_Cur_Page = parseInt(Cur_Url_ThreadCM.substring(i + 13))
        }
        for (i = 1; i <= Cm_Page_Num; i++) {
            if (i == Cm_Cur_Page) {
                strout += '<span>' + i + '</span>'
            } else {
                strout += '<a href="' + Org_Url_ThreadCM + '?commentPage=' + i + '#comments">' + i + '</a>'
            }
        }
        if (Cm_Cur_Page * 200 <= Cm_Total) {
            strout += '</div><div style="float:right">' + (((Cm_Cur_Page - 1) * 200) + 1) + ' - ' + (Cm_Cur_Page * 200) + ' of ' + Cm_Total + ' comments</div>'
        } else {
            strout += '</div><div style="float:right">' + (((Cm_Cur_Page - 1) * 200) + 1) + ' - ' + Cm_Total + ' of ' + Cm_Total + ' comments</div>'
        }
        var Cm_Page_Obj = document.getElementById('cm_page');
        Cm_Page_Obj.innerHTML = strout;
        Cm_Page_Obj = document.getElementById('cm_page_copy');
        Cm_Page_Obj.innerHTML = strout;
        if (Cm_Cur_Page < Cm_Page_Num) {
            strout = '<style type="text/css">.cm_author_reply {display: none}</style>';
            var Cm_ReplyCSS_Obj = document.getElementById('cm_reply_css');
            Cm_ReplyCSS_Obj.innerHTML = strout
        }
    }
}
//]]>

$(function() {
	var $imgs = $('.post img, .cm_entry img');
	$imgs.lazyload({
		placeholder:"",
		threshold:200
	});
});

